﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MovieRental.Entities;
using MovieRental_Presentation.Helpers;
using System.Collections.ObjectModel;
using MovieRental_Presentation.DataViews;


namespace MovieRental_Presentation
{
	public partial class NewCustomerDialog
	{
        private CustomerInfo _customer = new CustomerInfo();

		public NewCustomerDialog()
		{
			this.InitializeComponent();
            DataContext = _customer;
		}

		private void backButton_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			NavigationService.GoBack();
		}


        private bool ValidateInput()
        {
            return (firstNameTextBox.Validate() &&
                    lastNameTextBox.Validate() &&
                    emailTextBox.Validate() &&
                    phoneNoTextBox.Validate()); 
        }

		private void okButton_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            if (!ValidateInput())
                return;
            ComponentManager.Instance.CustomerComponent.AddOrUpdate(_customer);
            this.NavigationService.GoBack();
		}


	}
}